var LookUpSysOrgID="null"; // LookUpDept.tag中使用
var LookUpHospID="null"; // LookUpLoc.tag中使用
/**
 * 初始化科室病区详情对话框
 */
var CdcLocationInfoDlg = {
    validateFields: {
    	code: {
            validators: {
                notEmpty: {
                    message: '代码不能为空'
                }
            }
        },
    	description: {
            validators: {
                notEmpty: {
                    message: '描述不能为空'
                }
            }
        },
    	busLocTypeId: {
            validators: {
                notEmpty: {
                    message: '类型不能为空'
                }
            }
        },
    	busLocRoleId: {
            validators: {
                notEmpty: {
                    message: '角色不能为空'
                }
            }
        },
    	hospitalId: {
            validators: {
                notEmpty: {
                    message: '所属院区不能为空'
                }
            }
        },
    	dataId: {
            validators: {
                notEmpty: {
                    message: '业务数据类型不能为空'
                }
            }
        }
    }
};


/**
 * 关闭此对话框
 */
CdcLocationInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
CdcLocationInfoDlg.validate = function () {
    $('#cdcLocationInfoForm').data("bootstrapValidator").resetForm();
    $('#cdcLocationInfoForm').bootstrapValidator('validate');
    return $("#cdcLocationInfoForm").data('bootstrapValidator').isValid();
}

 CdcLocationInfoDlg.hospID="null";
CdcLocationInfoDlg.selectHosp = function(id,record){
    CdcLocationInfoDlg.hospID=record.value;
    LookUpHospID=CdcLocationInfoDlg.hospID;
    $("#lookup_parLocId").lookup("enable");
}
/**
 * 提交新增
 */
CdcLocationInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcLocationInfoForm',Sys.backendPath + "/cdc/cdclocation/add",function(res) {
        Sys.success(res.message);
    	window.parent.CdcLocation.table.refresh();
        CdcLocationInfoDlg.close();
    });
}

/**
 * 提交修改
 */
CdcLocationInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcLocationInfoForm',Sys.backendPath + "/cdc/cdclocation/update",function(res) {
        Sys.success(res.message);
    	window.parent.CdcLocation.table.refresh();
        CdcLocationInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("cdcLocationInfoForm", CdcLocationInfoDlg.validateFields);
    $("#dataId").combobox("disable");
    $("#dataId").combobox('setValue', window.parent.CdcLocation.sysDataId);
    if(!$("#hospitalId").val()) {
        $("#lookup_parLocId").lookup("disable");
    }else{
        CdcLocationInfoDlg.hospID=$("#hospitalId").val();
        LookUpHospID=CdcLocationInfoDlg.hospID;
    }
    CdcLocationInfoDlg.sysOrgId=window.parent.CdcLocation.sysOrgId;
    LookUpSysOrgID=CdcLocationInfoDlg.sysOrgId; // LookUpDept.tag中使用
});
